
import type { UploadImage } from '@/types/consult'
import { defineStore } from 'pinia'
import { ref } from 'vue'

// 1. 定义store
export const useConsultStore = defineStore(
  'consult',
  () => {
    const illnessInfo = ref({
      illnessDesc: '',
      illnessTime: 1,
      consultFlag: 1,

      pictures: [] as UploadImage[],
    })

    const type = ref('')
    // 问诊类型
    const illnessType = ref('')
    // 科室ID
    const depId = ref('')
    // 患者id
    const patientId = ref('')

    // 1. 定义清除数据的方法
    const clear = () => {
      illnessInfo.value = {
        illnessDesc: '',
        illnessTime: 1,
        consultFlag: 1,
        pictures: [],
      }

      type.value = ''
      illnessType.value = ''
      depId.value = ''
      patientId.value = ''
    }

    return { illnessInfo, type, illnessType, depId, patientId, clear }
  },

  {
    unistorage: true,
  }
)
